<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');
session_start(); //we need to call PHP's session object to access it through CI

class Final_Ratings_Controller extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->load->model('finalrating', '', 'TRUE');
        $this->load->model('user', '', true);
        
        if (!$this->session->userdata('logged_in')) {
            redirect('login', 'refresh');
        }
        
        $this->load->library('authentication');$this->load->helper('t');
        $this->loggedUser = $this->authentication->getLoggedUser();$this->authentication->redirectIfNotBe( array('HR', 'SC'));
    }

    function index() {
        $this->load->model('firstrating', '', 'TRUE');
        $this->load->model('attituderating', '', 'TRUE');
        
        $viewData['finalRatings'] = $this->finalrating->get_list();
        $viewData['firstRatings'] = $this->firstrating->get_list();
        $viewData['attRatings'] = $this->attituderating->get_list();
            
        $this->load->view(get_folder($this->loggedUser->title).'/final_ratings_edit', $viewData);

    }

    function setting() {
        $logged_in = $this->session->userdata('logged_in');
        if ($logged_in['su'] != "1") {
            exit('Permission denied');
            return;
        }

        $session_data = $this->session->userdata('logged_in');
        $data['username'] = $session_data['username'];
        $data['title'] = "Setting";
        $this->load->view(get_folder($this->loggedUser->title).'/header', $data);
        $this->load->view(get_folder($this->loggedUser->title).'/home_view_admin', $data);
        $this->load->view(get_folder($this->loggedUser->title).'/footer', $data);
    }

    function logout() {
        $this->load->helper('cookie');
        $this->session->unset_userdata('logged_in');
        $institute_id = $this->session->userdata('institute_id');
        $this->session->sess_destroy();
        session_destroy();
        delete_cookie("rid");
        redirect('login/index/' . urlencode(base64_encode($institute_id)), 'refresh');
    }

}
?>


